package fr.umlv.m2.jee.portailEtudiant.web.action.course;

import fr.umlv.m2.jee.portailEtudiant.persistence.*;
import org.dom4j.rule.Action;
import com.opensymphony.xwork2.ActionSupport;
import fr.umlv.m2.jee.portailEtudiant.service.DisplayCourse;
import fr.umlv.m2.jee.portailEtudiant.service.IDisplayCourseService;
import fr.umlv.m2.jee.portailEtudiant.service.Impl.DefaultDisplayCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: soufiane
 * Date: 07/02/11
 * Time: 12:32
 * To change this template use File | Settings | File Templates.
 */
public class CourseAction extends ActionSupport {

    @Autowired
    private IDisplayCourseService coursesService;

    private static List< DisplayCourse > courseList = new LinkedList< DisplayCourse >();

    private String name;

  
	public String lister_cours() throws Exception {
        System.out.println("ds execute 1");
		//courseList = coursesService.getAllDisplayCourses();
        System.out.println("ds execute 2");
		return SUCCESS;

	}

    public List< DisplayCourse > getCourseList() {
		return courseList;
	}


    public void setTdsService(IDisplayCourseService tdsService) {
        this.coursesService = coursesService;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String addCourse() {
        Course course = new Course();
        course.setName(name);

        System.out.println("LE NOM : "+name);

        DisplayCourse dcourse = new DisplayCourse(course);

        System.out.println("dcourse created");

        getCourseList().add(dcourse);

        System.out.println("added");
        return SUCCESS;
    }
}
